/**
 * ItemMgr.java
 * @author GorillaFunch
 * @created 2012.10.12
 */
package kr.ac.kongju.gedl.item.service.impl;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import kr.ac.kongju.gedl.attach.service.AttachFileService;
import kr.ac.kongju.gedl.attach.vo.AttachFileVO;
import kr.ac.kongju.gedl.common.util.ListResultVO;
import kr.ac.kongju.gedl.item.dao.ItemDAO;
import kr.ac.kongju.gedl.item.service.ItemService;
import kr.ac.kongju.gedl.item.vo.ItemFileVO;
import kr.ac.kongju.gedl.item.vo.ItemLevelVO;
import kr.ac.kongju.gedl.item.vo.ItemVO;
import kr.ac.kongju.gedl.item.vo.ItemVO;
import kr.ac.kongju.gedl.item.vo.ItemLinkVO;
import kr.ac.kongju.gedl.item.vo.ItemXmlVO;



import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;


import egovframework.rte.fdl.cmmn.AbstractServiceImpl;

@Service("itemService")
public class ItemServiceImpl  extends AbstractServiceImpl implements ItemService{
	// Log
	private final Logger logger = LoggerFactory.getLogger(getClass());
	
	@Resource(name="itemDAO")
    private ItemDAO itemDAO;
	
	@Resource(name="attachFileService")
	private AttachFileService attachFileService;

	/* (non-Javadoc)
	 * @see kr.ac.kongju.gedl.item.service.impl.ItemService#registerItemInfo(kr.ac.kongju.gedl.item.vo.ItemVO)
	 */
	@Override
	public ItemVO registerItemInfo(ItemVO itemInfo){
		ItemVO resultVO = itemDAO.registerItemInfo(itemInfo);
		List<AttachFileVO> attachFileList = itemInfo.getAttachFileList();
		if(attachFileList != null) {
			for(AttachFileVO attachFileVO : attachFileList) {
				attachFileVO.setContentsId(resultVO.getItemId());
				attachFileService.registerAttachFile(attachFileVO);
				
			}
		}
		
		return resultVO;
	}
	
	
	
	/* (non-Javadoc)
	 * @see kr.ac.kongju.gedl.item.service.impl.ItemService#retrieveItemLevel(kr.ac.kongju.gedl.item.vo.ItemVO)
	 */
	@Override
	public ItemVO retrieveItemInfo(ItemVO itemLevel) throws Exception{
		try {
			itemLevel = itemDAO.retrieveItemInfo(itemLevel);
		} catch (SQLException e) {
			logger.error("itemLevelId:{} Message:{}", itemLevel.getItemId(), e.toString());
		} 
		return itemLevel;
	}
	
	
	/* (non-Javadoc)
	 * @see kr.ac.kongju.gedl.item.service.impl.ItemService#retrieveListCountItemLevel(kr.ac.kongju.gedl.item.vo.ItemVO)
	 */
	@Override
	public int retrieveItemCount(ItemVO searchCondition) throws Exception{
		return itemDAO.retrieveItemCount(searchCondition);	
	}	
	
	/* (non-Javadoc)
	 * @see kr.ac.kongju.gedl.item.service.impl.ItemService#retrieveListItemLevel(kr.ac.kongju.gedl.item.vo.ItemVO)
	 */
	@Override
	public ListResultVO<ItemVO> retrieveItemList(ItemVO searchCondition) throws Exception{
		ListResultVO<ItemVO> listResult = new ListResultVO<ItemVO>();
		List<ItemVO> list = new ArrayList<ItemVO>();
		try {
			int count = itemDAO.retrieveItemCount(searchCondition);
			if(count > 0){
				list = itemDAO.retrieveItemList(searchCondition);
				listResult = new ListResultVO<ItemVO>(count, list);
			}
			//logger.info("count:{} list.size:{}", count, list.size());
		} catch (SQLException e) {
			logger.error("cause:{}", e.toString());
		} 	
		
		return listResult;	
	}



	@Override
	public int updateItemInfo(ItemVO itemInfo) {
		// TODO Auto-generated method stub
		return itemDAO.updateItemInfo(itemInfo);
	}



	@Override
	public int deleteItemInfo(String itemId) {
		// TODO Auto-generated method stub
		return itemDAO.deleteItemInfo(itemId);
	}



	@Override
	public String retrieveItemFront(String itemId) {
		// TODO Auto-generated method stub
		return null;
	}



	@Override
	public String retrieveLevelFront(String itemId, String levelId) {
		// TODO Auto-generated method stub
		return null;
	}



	@Override
	public ItemXmlVO retrieveItemXml(ItemXmlVO itemXml) throws Exception {
		// TODO Auto-generated method stub
		return null;
	}



	@Override
	public int retrieveListCountItemXml(ItemVO searchCondition)
			throws Exception {
		// TODO Auto-generated method stub
		return 0;
	}



	@Override
	public ListResultVO<ItemXmlVO> retrieveListItemXml(ItemVO searchCondition)
			throws Exception {
		// TODO Auto-generated method stub
		return null;
	}



	@Override
	public List<ItemXmlVO> retrieveListItemXml(String itemId, String xmlId)
			throws Exception {
		// TODO Auto-generated method stub
		return null;
	}



	@Override
	public ItemLevelVO updateItemLevelOtherTypes(ItemLevelVO itemLevel) {
		// TODO Auto-generated method stub
		return null;
	}



	@Override
	public int updateListItemLevelOtherTypes(List<ItemLevelVO> itemLevelList) {
		// TODO Auto-generated method stub
		return 0;
	}



	@Override
	public ItemLevelVO retrieveItemLevel(ItemLevelVO itemLevel)
			throws Exception {
		// TODO Auto-generated method stub
		return null;
	}



	@Override
	public ItemLevelVO retrieveItemLevelSimple(ItemLevelVO itemLevel)
			throws Exception {
		// TODO Auto-generated method stub
		return null;
	}



	@Override
	public int retrieveListCountItemLevel(ItemVO searchCondition)
			throws Exception {
		// TODO Auto-generated method stub
		return 0;
	}



	@Override
	public ListResultVO<ItemLevelVO> retrieveListItemLevel(
			ItemVO searchCondition) throws Exception {
		// TODO Auto-generated method stub
		return null;
	}



	@Override
	public List<ItemLevelVO> retrieveListItemLevelSimple(ItemVO searchCondition)
			throws Exception {
		// TODO Auto-generated method stub
		return null;
	}



	@Override
	public int retrieveListCountItemLevelGroupBy(ItemVO searchCondition)
			throws Exception {
		// TODO Auto-generated method stub
		return 0;
	}



	@Override
	public ListResultVO<ItemLevelVO> retrieveListItemLevelGroupBy(
			ItemVO searchCondition) throws Exception {
		// TODO Auto-generated method stub
		return null;
	}



	@Override
	public List<ItemLevelVO> retrieveListItemLevelYear(ItemVO searchCondition)
			throws Exception {
		// TODO Auto-generated method stub
		return null;
	}



	@Override
	public List<ItemLevelVO> retrieveListItemLevelDay(ItemVO searchCondition)
			throws Exception {
		// TODO Auto-generated method stub
		return null;
	}



	@Override
	public List<ItemLevelVO> retrieveParentListItemLevel(ItemLevelVO itemLevel)
			throws Exception {
		// TODO Auto-generated method stub
		return null;
	}



	@Override
	public List<ItemLevelVO> retrieveChildListItemLevel(ItemLevelVO itemLevel)
			throws Exception {
		// TODO Auto-generated method stub
		return null;
	}



	@Override
	public List<ItemLevelVO> retrieveSiblingListItemLevel(ItemLevelVO itemLevel)
			throws Exception {
		// TODO Auto-generated method stub
		return null;
	}



	@Override
	public String retrievePrevItemLevel(ItemLevelVO itemLevel) {
		// TODO Auto-generated method stub
		return null;
	}



	@Override
	public String retrieveNextItemLevel(ItemLevelVO itemLevel) {
		// TODO Auto-generated method stub
		return null;
	}



	@Override
	public List<ItemLevelVO> retrieveListItemLevelByItem(String category)
			throws Exception {
		// TODO Auto-generated method stub
		return null;
	}



	@Override
	public int retrieveListCountItemLevelEducation(ItemVO searchCondition)
			throws Exception {
		// TODO Auto-generated method stub
		return 0;
	}



	@Override
	public String retrieveChildText(String levelId) {
		// TODO Auto-generated method stub
		return null;
	}



	@Override
	public ItemFileVO retrieveChildImage(String levelId) {
		// TODO Auto-generated method stub
		return null;
	}



	@Override
	public ItemLevelVO retrieveItemLevelbyPage(String levelId, String page) {
		// TODO Auto-generated method stub
		return null;
	}



	@Override
	public ItemLevelVO retrieveChildItemLevelbyPage(String levelId) {
		// TODO Auto-generated method stub
		return null;
	}



	@Override
	public ItemFileVO retrieveItemFile(ItemFileVO itemFile) throws Exception {
		// TODO Auto-generated method stub
		return null;
	}



	@Override
	public int retrieveListCountItemFile(ItemVO searchCondition)
			throws Exception {
		// TODO Auto-generated method stub
		return 0;
	}



	@Override
	public ListResultVO<ItemFileVO> retrieveListItemFile(ItemVO searchCondition)
			throws Exception {
		// TODO Auto-generated method stub
		return null;
	}



	@Override
	public ItemFileVO updateItemFile(ItemFileVO itemFile) {
		// TODO Auto-generated method stub
		return null;
	}



	@Override
	public List<ItemVO> retrieveListItemfileGroupByItemId() throws Exception {
		// TODO Auto-generated method stub
		return null;
	}



	@Override
	public ItemLinkVO retrieveItemLink(ItemLinkVO itemLink) {
		// TODO Auto-generated method stub
		return null;
	}



	@Override
	public int retrieveListCountItemLink(ItemVO searchCondition)
			throws Exception {
		// TODO Auto-generated method stub
		return 0;
	}



	@Override
	public ListResultVO<ItemLinkVO> retrieveListItemLink(ItemVO searchCondition)
			throws Exception {
		// TODO Auto-generated method stub
		return null;
	}



	@Override
	public ItemLevelVO retrieveItemLevelWithoutXML(ItemLevelVO itemLevel)
			throws Exception {
		// TODO Auto-generated method stub
		return null;
	}



	@Override
	public String retrieveItemLevelXML(ItemLevelVO itemLevel) throws Exception {
		// TODO Auto-generated method stub
		return null;
	}
	
	
	
	
}
